from typing import Optional

from model.uml_base import UmlBase
from model.uml_comment import UmlComment


class UmlElement(UmlBase):
    def __init__(self, xmi_type="") -> None:
        super().__init__(xmi_type)
        self.ownedComment: Optional[UmlComment] = None

    def to_json(self) -> dict[str, object]:
        json: dict = super().to_json()

        if self.ownedComment is not None:
            json["ownedComment"] = self.ownedComment.to_json()

        return json

    def from_json(self, json: dict):
        if json is None:
            return
